//
//  GYNaviView.m
//  GoodLuck
//
//  Created by apple on 2018/2/2.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

#import "GYNaviView.h"

@interface GYNaviView ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *markLableLeftMarginCons;

//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *markLableleadingCons;
//
//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *btuLeftMarginCons;
//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *btuRightMarginCons;

@property (weak, nonatomic) IBOutlet UIButton *shopBtu;
@property (weak, nonatomic) IBOutlet UIButton *shopDetailesBtu;
@property (weak, nonatomic) IBOutlet UIButton *shopEvaluateBtu;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *btuWidthCons;

@end

@implementation GYNaviView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.shopBtu.contentEdgeInsets = UIEdgeInsetsMake(-15, 0, 0, 0);
    self.shopDetailesBtu.contentEdgeInsets = UIEdgeInsetsMake(-15, 0, 0, 0);
    self.shopEvaluateBtu.contentEdgeInsets = UIEdgeInsetsMake(-15, 0, 0, 0);
    self.btuWidthCons.constant = [GYAutoScale widthScale:37 originalSize:iphone6_W];
    
}

- (IBAction)btuClick:(UIButton *)sender {
    [self.delegate naviBtuClick:sender.tag];
    
    [self updateMarkLable:sender.tag];
    
}

//适配IOS11的导航中间titleView图层变化 ios10级以下是添加在UINavigationBar上面  IOS11是添加在UINavigationBarContentView上

- (CGSize)intrinsicContentSize {
    return UILayoutFittingExpandedSize;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
//    self.btuLeftMarginCons.constant = widthScale(60, iphone6_W);
//    self.btuRightMarginCons.constant = widthScale(60, iphone6_W);
    self.shopBtu.titleLabel.font = [UIFont systemFontOfSize:widthScale(18, iphone6_W)];
    self.shopDetailesBtu.titleLabel.font = [UIFont systemFontOfSize:widthScale(18, iphone6_W)];
    self.shopEvaluateBtu.titleLabel.font = [UIFont systemFontOfSize:widthScale(18, iphone6_W)];
}

- (void)updateMarkLable:(NSInteger)index {
    [UIView animateWithDuration:0.5 animations:^{
        self.markLableLeftMarginCons.constant = (self.shopBtu.width+20) * (index-1);
        [self setNeedsLayout];
    }];
}

@end
